<template>
  <van-popup v-model="visible" position="bottom" class="wallet-selection">
    <div class="header">
      <div>选择币种</div>
      <button class="close-btn" @click="close">✕</button>
    </div>
    <div
      v-for="(wallet, index) in wallets"
      :key="index"
      class="wallet-item"
      @click="selectWallet(wallet)"
    >
      <div class="flex-warp justify-start items-center">
        <img
          :src="require(`../assets/image/icon/${wallet.name}.png`)"
          class="wallet-icon"
        />
        <span>{{ wallet.name }}</span>
      </div>

      <div class="wallet-checkmark">
        <!-- 根据是否选中，显示对号 -->
        <img
          v-if="selectedWallet.name === wallet.name"
          src="../assets/image/home/langright.png"
          alt="checkmark"
          class="rightimg"
        />
        <div v-else class="flaseimg"></div>
      </div>
    </div>
    <div class="btnbox">
      <div @click="surecoin" class="confirm-btn">{{ $t("side.side5") }}</div>
    </div>
  </van-popup>
</template>

<script>
export default {
  props: {
    value: Boolean, // 用于控制弹出层显示的 v-model
  },
  data() {
    return {
      visible: this.value,
      wallets: [
        {
          name: "USDT",
          show: true,
        },
        {
          name: "BNB",
          show: false,
        },
        {
          name: "ETH",
          show: false,
        },
        {
          name: "DOGE",
          show: false,
        },
        {
          name: "AAVE",
          show: false,
        },
        {
          name: "CAKE",
          show: false,
        },
        {
          name: "GMT",
          show: false,
        },
        {
          name: "DOT",
          show: false,
        },
        {
          name: "FIL",
          show: false,
        },
      ],
      selectedWallet: null,
    };
  },
  watch: {
    value(val) {
      this.visible = val;
    },
    visible(val) {
      this.$emit("input", val);
    },
  },
  computed: {},
  created() {
    if (this.wallets) {
      this.selectedWallet = this.wallets[0];
    }
  },
  methods: {
    selectWallet(wallet) {
      if (wallet.show) {
        this.selectedWallet = wallet;
      }
    },
    surecoin() {
      this.$emit("select", this.selectedWallet);
      this.close(); // 关闭弹出层
    },

    close() {
      this.visible = false;
    },
  },
};
</script>

<style lang="less" scoped>
.van-popup {
  height: 1000px;
  // background-color: #1f1b3b;
  background: linear-gradient( #1b1738, #141418,);

}
.wallet-selection {
  padding: 38px;
  text-align: center;
  color: white;
  padding-bottom: 200px;
}

.header {
  font-weight: 500;
  font-size: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #363636;
  margin-bottom: 40x;
  padding-bottom: 36px;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 30px;
  cursor: pointer;
}

.wallet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0;
  padding: 22px 34px;
  // border: 2px solid #363636;
  background: #282443;
  border-radius: 16px;
}

.wallet-icon {
  width: 48px;
  height: 48px;
  margin-right: 28px;
}

.rightimg {
  width: 32px;
  height: 32px;
}

.flaseimg {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #928f93;
}
.btnbox {
  width: 100%;
  position: fixed;
  background: #141418;
  bottom: 0;
  padding: 0 38px;
  left: 0;
  right: 0;
}
.confirm-btn {
  box-sizing: border-box;
  width: 100%;
  height: 100px;
  background: linear-gradient(90deg, #3D66BE, #D53E9B,);
 
  border-radius: 64px;
  text-align: center;
  line-height: 100px;
  font-weight: 500;
  font-size: 30px;
  margin: 50px 0;
}
</style>
